package com.itheima.user.controller;

import com.itheima.user.pojo.User;
import com.itheima.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@RefreshScope //刷新配置
public class UserController {
    @Autowired
    private UserService userService;
    @Value("${heima}")
    private String name;

    /**
     * 根据id查询用户信息
     * @param username
     * @return
     */
    @GetMapping("/{username}")
    public User findUserById(@PathVariable("username") String username){
        System.out.println(name);
        return userService.findUserById(username);
    }
}
